package com.agino.springboot.learn.ddd.hotel;

import lombok.Data;

@Data
public class RoomSeatMapper {
    public static Seat toSeat(Room room) {
        Seat seat = new Seat();
        seat.setId(room.getId());
        seat.setPosition(""); // 座位上没有位置信息
        seat.setPrice(room.getPrice());
        seat.setStatus(room.getStatus().equals(RoomStatus.FREE) ? SeatStatus.FREE : SeatStatus.BOOKED); // 房间空闲时，对应的座位就是空闲状态；房间被预订时，对应的座位就是被预订状态。
        return seat;
    }

    public static Room toRoom(Seat seat) {
        Room room = new Room();
        room.setId(seat.getId());
        room.setSize(0); // 对于航班座位，没有大小属性
        room.setPrice(seat.getPrice());
        room.setStatus(seat.getStatus().equals(SeatStatus.FREE) ? RoomStatus.FREE : RoomStatus.BOOKED);
        return room;
    }
}
